package com.itheima.easy.mapper;

import com.github.pagehelper.Page;
import com.itheima.easy.entity.Dept;
import com.itheima.easy.vo.DeptVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface DeptMapper {

    int deleteByPrimaryKey(Long id);

    int insert(Dept record);

    int insertSelective(Dept record);

    Dept selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(Dept record);

    int updateByPrimaryKey(Dept record);

    int batchInsert(@Param("list") List<Dept> list);

    Page<List<Dept>> selectPage(@Param("deptVo") DeptVo deptVo);

    List<Dept> selectList(@Param("deptVo") DeptVo deptVo);

    List<Dept> findDeptInDeptNos(@Param("deptNos")List<String> deptNos);

    List<Dept> findDeptListByUserId(Long userId);

    List<DeptVo> findDeptVoListInRoleId(@Param("roleIds")List<Long> roleIds);

    Dept selectByDeptNo(@Param("deptNo") String deptNo);

    /**
     * 是否存在子节点
     *
     * @param deptId 部门ID
     * @return 结果
     */
    public int hasChildByDeptId(@Param("deptId") String deptId);

    /**
     * 查询部门是否存在用户
     *
     * @param deptId 部门ID
     * @return 结果
     */
    public int checkDeptExistUser(@Param("deptId") String deptId);

    /**
     * 删除部门管理信息
     *
     * @param deptId 部门ID
     * @return 结果
     */
    public int deleteDeptById(@Param("deptId") String deptId);

    @Select("select dept_no from  tab_dept where dept_name = #{deptName}")
    String selectByDeptName(@Param("deptName") String deptName);
}
